# 安装要用的包
import os
import openai

# 设置环境变量，等号后面的引号里面用你自己的api key哦
os.environ['OPENAI_API_KEY'] = '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'

# 开始openai
openai.api_key = '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'

proxies = {'http': "http://127.0.0.1:7890",
'https': "http://127.0.0.1:7890"}
openai.proxy = proxies

# 设置，prompt是要输入的描述性文字，size是大小，但只可以在'256x256', '512x512', '1024x1024'里面选
response = openai.Image.create(
  prompt="""墓左青草被踏坏了一片，墓门进口处有兵器撞击的痕迹。她在墓门口倾听半晌，没听到里面有甚响
动，这才弯腰入门。郭靖恐她有失，亦步亦趋的跟随。眼见墓道中石壁到处碎裂，显见经过
一番恶斗，两人更是惊疑不定。走出数丈，黄蓉俯身拾起一物。墓道中虽然昏暗，却隐约可
辨正是全金发的半截秤杆。这秤杆乃镔铁铸成，粗若儿臂，这时却被人生生折成两截。""",
  n=1,
  size="512x512"
)

image_url = response['data'][0]['url']
print(image_url)